﻿<!DOCTYPE html>
<!--[if IE]><![endif]-->
<html>

  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>Class SECSConnection
 </title>
    <meta name="viewport" content="width=device-width">
    <meta name="title" content="Class SECSConnection
 ">
  
    <link rel="shortcut icon" href="../../favicon.ico">
    <link rel="stylesheet" href="../../styles/docfx.vendor.css">
    <link rel="stylesheet" href="../../styles/docfx.css">
    <link rel="stylesheet" href="../../styles/main.css">
    <meta property="docfx:navrel" content="../../toc.html">
    <meta property="docfx:tocrel" content="toc.html">
  
  
  
  </head>
  <body data-spy="scroll" data-target="#affix" data-offset="120">
    <div id="wrapper">
      <header>

        <nav id="autocollapse" class="navbar navbar-inverse ng-scope" role="navigation">
          <div class="container">
            <div class="navbar-header">
              <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
              </button>

              <a class="navbar-brand" href="../../index.html">
                <img id="logo" class="svg" src="../../logo.svg" alt="">
              </a>
            </div>
            <div class="collapse navbar-collapse" id="navbar">
              <form class="navbar-form navbar-right" role="search" id="search">
                <div class="form-group">
                  <input type="text" class="form-control" id="search-query" placeholder="Search" autocomplete="off">
                </div>
              </form>
            </div>
          </div>
        </nav>

        <div class="subnav navbar navbar-default">
          <div class="container hide-when-search" id="breadcrumb">
            <ul class="breadcrumb">
              <li></li>
            </ul>
          </div>
        </div>
      </header>
      <div role="main" class="container body-content hide-when-search">

        <div class="sidenav hide-when-search">
          <a class="btn toc-toggle collapse" data-toggle="collapse" href="#sidetoggle" aria-expanded="false" aria-controls="sidetoggle">Show / Hide Table of Contents</a>
          <div class="sidetoggle collapse" id="sidetoggle">
            <div id="sidetoc"></div>
          </div>
        </div>
        <div class="article row grid-right">
          <div class="col-md-10">
            <article class="content wrap" id="_content" data-uid="com.CIMthetics.CSharpSECSTools.SECSCommUtils.SECSConnection">


  <h1 id="com_CIMthetics_CSharpSECSTools_SECSCommUtils_SECSConnection" data-uid="com.CIMthetics.CSharpSECSTools.SECSCommUtils.SECSConnection" class="text-break">Class SECSConnection
</h1>
  <div class="markdown level0 summary"><p>This is the <code>abstract</code> base class for classes supporting communication of SECS-II
messages to an end point.</p>
</div>
  <div class="markdown level0 conceptual"></div>
  <div class="inheritance">
    <h5>Inheritance</h5>
    <div class="level0"><span class="xref">System.Object</span></div>
    <div class="level1"><span class="xref">SECSConnection</span></div>
      <div class="level2"><a class="xref" href="com.CIMthetics.CSharpSECSTools.SECSCommUtils.HSMSConnection.html">HSMSConnection</a></div>
      <div class="level2"><a class="xref" href="com.CIMthetics.CSharpSECSTools.SECSCommUtils.SECSIConnection.html">SECSIConnection</a></div>
  </div>
  <h6><strong>Namespace</strong>: <a class="xref" href="com.CIMthetics.CSharpSECSTools.SECSCommUtils.html">com.CIMthetics.CSharpSECSTools.SECSCommUtils</a></h6>
  <h6><strong>Assembly</strong>: SECSCommUtils.dll</h6>
  <h5 id="com_CIMthetics_CSharpSECSTools_SECSCommUtils_SECSConnection_syntax">Syntax</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public abstract class SECSConnection</code></pre>
  </div>
  <h5 id="com_CIMthetics_CSharpSECSTools_SECSCommUtils_SECSConnection_remarks"><strong>Remarks</strong></h5>
  <div class="markdown level0 remarks"><p>SECS messages (<code>SECSMessage</code>s) are sent using the <code>SendMessage</code> method.  When this method returns
it does not imply that the message has already been sent.  It just means the message
has been queued to be sent.  In normal situations the message will be sent almost
immediately.</p>
<p>
When messages are received by this connection they are placed at the end of the
thread safe <code>MessagesReceivedQueue</code>.  The user is able to remove message
from this queue and process them.
</p>
<p>
A <code>SECSConnection</code> is used in the following manner.
<ol>
<li>Use <code>SECSConnectionFactory.CreateConnection</code> to create a <code>SECSConnection</code> object.</li>
<li>
Start the <code>SECSConnection</code> using the <code>Start</code> method.  This method basically
&quot;wakes up&quot; the connection in that it will actively prepare itself for communicating
with an end point.  Returning from the <code>Start</code> method does not mean that a connection
has been successfully established with the end point.  It just means that this connection is
ready and willing to communicate depending on the end point.
</li>
<li>
Once a connection to the end point has been established.  (Which may not happen immediately after
the completion of the <code>Start</code> method.)  The user may use the <code>SendMessage</code> method to
send a message or they may add a message directly to the end of the <code>MessagesToSendQueue</code>.
<p>
Received messages will be on the <code>MessagesReceivedQueue</code>.  The user can either block on
the queue awaiting the receipt or a message or poll the queue if blocking is not acceptable.
In normal cases a separate thread will block on the queue awaiting messages to process.
</p>
</li>
<li>
When the connection is no longer needed use the <code>Stop</code> method to perform a more graceful shutdown.
</li>
</ol>

</div>
  <h3 id="constructors">Constructors
</h3>


  <a id="com_CIMthetics_CSharpSECSTools_SECSCommUtils_SECSConnection__ctor_" data-uid="com.CIMthetics.CSharpSECSTools.SECSCommUtils.SECSConnection.#ctor*"></a>
  <h4 id="com_CIMthetics_CSharpSECSTools_SECSCommUtils_SECSConnection__ctor_System_String_" data-uid="com.CIMthetics.CSharpSECSTools.SECSCommUtils.SECSConnection.#ctor(System.String)">SECSConnection(String)</h4>
  <div class="markdown level1 summary"><p>This is the <code>abstract</code> base class for classes supporting communication of SECS-II
messages to an end point.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="declaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">protected SECSConnection(string ConnectionName)</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.String</span></td>
        <td><span class="parametername">ConnectionName</span></td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 id="com_CIMthetics_CSharpSECSTools_SECSCommUtils_SECSConnection__ctor_System_String__remarks">Remarks</h5>
  <div class="markdown level1 remarks"><p>SECS messages (<code>SECSMessage</code>s) are sent using the <code>SendMessage</code> method.  When this method returns
it does not imply that the message has already been sent.  It just means the message
has been queued to be sent.  In normal situations the message will be sent almost
immediately.</p>
<p>
When messages are received by this connection they are placed at the end of the
thread safe <code>MessagesReceivedQueue</code>.  The user is able to remove message
from this queue and process them.
</p>
<p>
A <code>SECSConnection</code> is used in the following manner.
<ol>
<li>Use <code>SECSConnectionFactory.CreateConnection</code> to create a <code>SECSConnection</code> object.</li>
<li>
Start the <code>SECSConnection</code> using the <code>Start</code> method.  This method basically
&quot;wakes up&quot; the connection in that it will actively prepare itself for communicating
with an end point.  Returning from the <code>Start</code> method does not mean that a connection
has been successfully established with the end point.  It just means that this connection is
ready and willing to communicate depending on the end point.
</li>
<li>
Once a connection to the end point has been established.  (Which may not happen immediately after
the completion of the <code>Start</code> method.)  The user may use the <code>SendMessage</code> method to
send a message or they may add a message directly to the end of the <code>MessagesToSendQueue</code>.
<p>
Received messages will be on the <code>MessagesReceivedQueue</code>.  The user can either block on
the queue awaiting the receipt or a message or poll the queue if blocking is not acceptable.
In normal cases a separate thread will block on the queue awaiting messages to process.
</p>
</li>
<li>
When the connection is no longer needed use the <code>Stop</code> method to perform a more graceful shutdown.
</li>
</ol>

</div>
  <h3 id="properties">Properties
</h3>


  <a id="com_CIMthetics_CSharpSECSTools_SECSCommUtils_SECSConnection_ConnectionName_" data-uid="com.CIMthetics.CSharpSECSTools.SECSCommUtils.SECSConnection.ConnectionName*"></a>
  <h4 id="com_CIMthetics_CSharpSECSTools_SECSCommUtils_SECSConnection_ConnectionName" data-uid="com.CIMthetics.CSharpSECSTools.SECSCommUtils.SECSConnection.ConnectionName">ConnectionName</h4>
  <div class="markdown level1 summary"><p>This a human meaningful name assigned to this <code>SECSConnection</code>.
It will appear in Log output in the event of issues.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="declaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public string ConnectionName { get; }</code></pre>
  </div>
  <h5 class="propertyValue">Property Value</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.String</span></td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 id="com_CIMthetics_CSharpSECSTools_SECSCommUtils_SECSConnection_ConnectionName_remarks">Remarks</h5>
  <div class="markdown level1 remarks"><p>SECS messages (<code>SECSMessage</code>s) are sent using the <code>SendMessage</code> method.  When this method returns
it does not imply that the message has already been sent.  It just means the message
has been queued to be sent.  In normal situations the message will be sent almost
immediately.</p>
<p>
When messages are received by this connection they are placed at the end of the
thread safe <code>MessagesReceivedQueue</code>.  The user is able to remove message
from this queue and process them.
</p>
<p>
A <code>SECSConnection</code> is used in the following manner.
<ol>
<li>Use <code>SECSConnectionFactory.CreateConnection</code> to create a <code>SECSConnection</code> object.</li>
<li>
Start the <code>SECSConnection</code> using the <code>Start</code> method.  This method basically
&quot;wakes up&quot; the connection in that it will actively prepare itself for communicating
with an end point.  Returning from the <code>Start</code> method does not mean that a connection
has been successfully established with the end point.  It just means that this connection is
ready and willing to communicate depending on the end point.
</li>
<li>
Once a connection to the end point has been established.  (Which may not happen immediately after
the completion of the <code>Start</code> method.)  The user may use the <code>SendMessage</code> method to
send a message or they may add a message directly to the end of the <code>MessagesToSendQueue</code>.
<p>
Received messages will be on the <code>MessagesReceivedQueue</code>.  The user can either block on
the queue awaiting the receipt or a message or poll the queue if blocking is not acceptable.
In normal cases a separate thread will block on the queue awaiting messages to process.
</p>
</li>
<li>
When the connection is no longer needed use the <code>Stop</code> method to perform a more graceful shutdown.
</li>
</ol>

</div>


  <a id="com_CIMthetics_CSharpSECSTools_SECSCommUtils_SECSConnection_MessagesReceivedQueue_" data-uid="com.CIMthetics.CSharpSECSTools.SECSCommUtils.SECSConnection.MessagesReceivedQueue*"></a>
  <h4 id="com_CIMthetics_CSharpSECSTools_SECSCommUtils_SECSConnection_MessagesReceivedQueue" data-uid="com.CIMthetics.CSharpSECSTools.SECSCommUtils.SECSConnection.MessagesReceivedQueue">MessagesReceivedQueue</h4>
  <div class="markdown level1 summary"><p>This is a thread safe queue where <code>SECSMessage</code>s that that have been received
will be placed asynchronously.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="declaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public BlockingCollection&lt;SECSMessage&gt; MessagesReceivedQueue { get; }</code></pre>
  </div>
  <h5 class="propertyValue">Property Value</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Collections.Concurrent.BlockingCollection</span>&lt;<a class="xref" href="com.CIMthetics.CSharpSECSTools.SECSCommUtils.SECSMessage.html">SECSMessage</a>&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 id="com_CIMthetics_CSharpSECSTools_SECSCommUtils_SECSConnection_MessagesReceivedQueue_remarks">Remarks</h5>
  <div class="markdown level1 remarks"><p>SECS messages (<code>SECSMessage</code>s) are sent using the <code>SendMessage</code> method.  When this method returns
it does not imply that the message has already been sent.  It just means the message
has been queued to be sent.  In normal situations the message will be sent almost
immediately.</p>
<p>
When messages are received by this connection they are placed at the end of the
thread safe <code>MessagesReceivedQueue</code>.  The user is able to remove message
from this queue and process them.
</p>
<p>
A <code>SECSConnection</code> is used in the following manner.
<ol>
<li>Use <code>SECSConnectionFactory.CreateConnection</code> to create a <code>SECSConnection</code> object.</li>
<li>
Start the <code>SECSConnection</code> using the <code>Start</code> method.  This method basically
&quot;wakes up&quot; the connection in that it will actively prepare itself for communicating
with an end point.  Returning from the <code>Start</code> method does not mean that a connection
has been successfully established with the end point.  It just means that this connection is
ready and willing to communicate depending on the end point.
</li>
<li>
Once a connection to the end point has been established.  (Which may not happen immediately after
the completion of the <code>Start</code> method.)  The user may use the <code>SendMessage</code> method to
send a message or they may add a message directly to the end of the <code>MessagesToSendQueue</code>.
<p>
Received messages will be on the <code>MessagesReceivedQueue</code>.  The user can either block on
the queue awaiting the receipt or a message or poll the queue if blocking is not acceptable.
In normal cases a separate thread will block on the queue awaiting messages to process.
</p>
</li>
<li>
When the connection is no longer needed use the <code>Stop</code> method to perform a more graceful shutdown.
</li>
</ol>

</div>


  <a id="com_CIMthetics_CSharpSECSTools_SECSCommUtils_SECSConnection_MessagesToSendQueue_" data-uid="com.CIMthetics.CSharpSECSTools.SECSCommUtils.SECSConnection.MessagesToSendQueue*"></a>
  <h4 id="com_CIMthetics_CSharpSECSTools_SECSCommUtils_SECSConnection_MessagesToSendQueue" data-uid="com.CIMthetics.CSharpSECSTools.SECSCommUtils.SECSConnection.MessagesToSendQueue">MessagesToSendQueue</h4>
  <div class="markdown level1 summary"><p>This is a thread safe queue where <code>SECSMessage</code>s that need to be sent should
be placed.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="declaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public BlockingCollection&lt;SECSMessage&gt; MessagesToSendQueue { get; }</code></pre>
  </div>
  <h5 class="propertyValue">Property Value</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><span class="xref">System.Collections.Concurrent.BlockingCollection</span>&lt;<a class="xref" href="com.CIMthetics.CSharpSECSTools.SECSCommUtils.SECSMessage.html">SECSMessage</a>&gt;</td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 id="com_CIMthetics_CSharpSECSTools_SECSCommUtils_SECSConnection_MessagesToSendQueue_remarks">Remarks</h5>
  <div class="markdown level1 remarks"><p>Normally you would send messages by using the <code>SendMessage</code> method, however, there
are situations where being able add messages directly to the send queue is
a better fit.</p>
</div>
  <h3 id="methods">Methods
</h3>


  <a id="com_CIMthetics_CSharpSECSTools_SECSCommUtils_SECSConnection_SendMessage_" data-uid="com.CIMthetics.CSharpSECSTools.SECSCommUtils.SECSConnection.SendMessage*"></a>
  <h4 id="com_CIMthetics_CSharpSECSTools_SECSCommUtils_SECSConnection_SendMessage_com_CIMthetics_CSharpSECSTools_SECSCommUtils_SECSMessage_" data-uid="com.CIMthetics.CSharpSECSTools.SECSCommUtils.SECSConnection.SendMessage(com.CIMthetics.CSharpSECSTools.SECSCommUtils.SECSMessage)">SendMessage(SECSMessage)</h4>
  <div class="markdown level1 summary"><p>This method is used to place an outbound <code>SECSMessage</code> into
the queue of messages that are to be sent to the other end of a
connection.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="declaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public void SendMessage(SECSMessage message)</code></pre>
  </div>
  <h5 class="parameters">Parameters</h5>
  <table class="table table-bordered table-striped table-condensed">
    <thead>
      <tr>
        <th>Type</th>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><a class="xref" href="com.CIMthetics.CSharpSECSTools.SECSCommUtils.SECSMessage.html">SECSMessage</a></td>
        <td><span class="parametername">message</span></td>
        <td></td>
      </tr>
    </tbody>
  </table>
  <h5 id="com_CIMthetics_CSharpSECSTools_SECSCommUtils_SECSConnection_SendMessage_com_CIMthetics_CSharpSECSTools_SECSCommUtils_SECSMessage__remarks">Remarks</h5>
  <div class="markdown level1 remarks"><p>The message is sent as soon as possible.  It may or may not be sent
before this method returns.</p>
</div>


  <a id="com_CIMthetics_CSharpSECSTools_SECSCommUtils_SECSConnection_Start_" data-uid="com.CIMthetics.CSharpSECSTools.SECSCommUtils.SECSConnection.Start*"></a>
  <h4 id="com_CIMthetics_CSharpSECSTools_SECSCommUtils_SECSConnection_Start" data-uid="com.CIMthetics.CSharpSECSTools.SECSCommUtils.SECSConnection.Start">Start()</h4>
  <div class="markdown level1 summary"><p>Calling this method effectively starts up this <code>SECSConnection</code>
and gets it into a state whereby it will attempt to establish a
connection to an end point using the configured information.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="declaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public abstract void Start()</code></pre>
  </div>
  <h5 id="com_CIMthetics_CSharpSECSTools_SECSCommUtils_SECSConnection_Start_remarks">Remarks</h5>
  <div class="markdown level1 remarks"><p>When this method returns a connection with the configured end point may or may
not be established.  This connection has been transitioned into a &quot;mode&quot;
in which it will actively attempt to establish a connection.</p>
</div>


  <a id="com_CIMthetics_CSharpSECSTools_SECSCommUtils_SECSConnection_Stop_" data-uid="com.CIMthetics.CSharpSECSTools.SECSCommUtils.SECSConnection.Stop*"></a>
  <h4 id="com_CIMthetics_CSharpSECSTools_SECSCommUtils_SECSConnection_Stop" data-uid="com.CIMthetics.CSharpSECSTools.SECSCommUtils.SECSConnection.Stop">Stop()</h4>
  <div class="markdown level1 summary"><p>Calling this method results in the shutting down of this <code>SECSConnection</code>.
The communication connection is closed and any worker <code>Threads</code> are
terminated.</p>
</div>
  <div class="markdown level1 conceptual"></div>
  <h5 class="declaration">Declaration</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public abstract void Stop()</code></pre>
  </div>
  <h5 id="com_CIMthetics_CSharpSECSTools_SECSCommUtils_SECSConnection_Stop_remarks">Remarks</h5>
  <div class="markdown level1 remarks"><p>SECS messages (<code>SECSMessage</code>s) are sent using the <code>SendMessage</code> method.  When this method returns
it does not imply that the message has already been sent.  It just means the message
has been queued to be sent.  In normal situations the message will be sent almost
immediately.</p>
<p>
When messages are received by this connection they are placed at the end of the
thread safe <code>MessagesReceivedQueue</code>.  The user is able to remove message
from this queue and process them.
</p>
<p>
A <code>SECSConnection</code> is used in the following manner.
<ol>
<li>Use <code>SECSConnectionFactory.CreateConnection</code> to create a <code>SECSConnection</code> object.</li>
<li>
Start the <code>SECSConnection</code> using the <code>Start</code> method.  This method basically
&quot;wakes up&quot; the connection in that it will actively prepare itself for communicating
with an end point.  Returning from the <code>Start</code> method does not mean that a connection
has been successfully established with the end point.  It just means that this connection is
ready and willing to communicate depending on the end point.
</li>
<li>
Once a connection to the end point has been established.  (Which may not happen immediately after
the completion of the <code>Start</code> method.)  The user may use the <code>SendMessage</code> method to
send a message or they may add a message directly to the end of the <code>MessagesToSendQueue</code>.
<p>
Received messages will be on the <code>MessagesReceivedQueue</code>.  The user can either block on
the queue awaiting the receipt or a message or poll the queue if blocking is not acceptable.
In normal cases a separate thread will block on the queue awaiting messages to process.
</p>
</li>
<li>
When the connection is no longer needed use the <code>Stop</code> method to perform a more graceful shutdown.
</li>
</ol>

</div>
</article>
          </div>

          <div class="hidden-sm col-md-2" role="complementary">
            <div class="sideaffix">
              <div class="contribution">
                <ul class="nav">
                </ul>
              </div>
              <nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
                <h5>In This Article</h5>
                <div></div>
              </nav>
            </div>
          </div>
        </div>
      </div>

      <footer>
        <div class="grad-bottom"></div>
        <div class="footer">
          <div class="container">
            <span class="pull-right">
              <a href="#top">Back to top</a>
            </span>
      
      <span>Generated by <strong>DocFX</strong></span>
          </div>
        </div>
      </footer>
    </div>

    <script type="text/javascript" src="../../styles/docfx.vendor.js"></script>
    <script type="text/javascript" src="../../styles/docfx.js"></script>
    <script type="text/javascript" src="../../styles/main.js"></script>
  </body>
</html>
